package org.example.node;

/**
 * @author liyishan
 * @date 2024/9/5 13:28
 * @apiNote
 */

public class M0202KthToLast {
    public int kthToLast(ListNode head, int k) {
        ListNode pre = head,cur = head;
        for(int i = 0;i<k;i++){
            cur = cur.next;
        }
        while(cur != null){
            pre = pre.next;
            cur = cur.next;
        }
        return pre.val;
    }
}
